<template>
  <div>
    <div>
      <MySubject 
      @input="item.result=$event"
      :obj="item"
      v-for="(item,index) in arr" :key="index"></MySubject>
    </div>
    <div>
      <MyFlag 
      :obj="item"
      v-for="(item,index) in arr" :key="index" :index="index"></MyFlag>
    </div>
  </div>
</template>

<script>
// 2:把数组传到子组件
import MySubject from '@/components/my-subject.vue'
import MyFlag from '@/components/my-flag.vue'
export default {
  created(){
    // 初始化就锝到一组数据
 const arr = []
 for(let i = 0; i < 5; i++){
  const left = Math.floor(Math.random()*11)
  const right = Math.floor(Math.random()*11)
  // 把这个数据做成一个对象锝形式，result是结果
  arr.push({left,right,result:null})
 }
 this.arr=arr
},
  data(){
    return {
      arr:[]
    }
  },
  components:{
    MySubject,
    MyFlag,
  }
}
</script>

<style scoped>

</style>